<?php
require_once 'modules/service/baseService.php';
require_once 'modules/dao/constants.php';
require_once 'modules/service/constants.php';

abstract class CommonService extends BaseService {

    /**
     * @desc 服务层通用接口 注意，只用于服务层的接口
     * @return unknown
     */
    
    /**
     * @desc DAO通道
     *
     */
    protected function getDaoFactory () {
        require_once 'modules/dao/daoFactory.php';
        return daoFactory::getInstance();
    }

    /**
     * @desc 检查字段函数
     * @param $fields 检查的数组
     * @param $validKeys 有效的数组key
     */
    protected function checkFields (array $fields, $validKeys = array()) {
        if (count($fields) < 0) {
            return array();
        }
        $tmpArray = array();
        $fields = $this->checkParams($fields);
        if (!$fields) {
            return array();
        }
        foreach ($fields as $key => $value) {
            if (!in_array($key, $validKeys)) {
                continue;
            }
            $tmpArray[$key] = $value;
        }
        return ($tmpArray) ? $tmpArray : array();
    }
}
